/*
 * Copyright (C) 2016-2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package com.astudio.lhasa.constants;

public class Languages {

    private static final String[] ONLINE_TRANSLATOR_LANG_ARRAY = {"en", "zh", "za", "zh"};
    private static final String[] SPEECH_LANG_ARRAY = {"english", "mandarin", "tibetan", "mandarin"};

    public static final int LANGUAGE_NAME_TYPE_FOR_SPEECH_RECOGNIZER = 1;
    public static final int LANGUAGE_NAME_TYPE_FOR_ONLINE_TRANSLATOR = 2;

    public static final int INTERPRETER_LANGUAGE_ENGLISH           = 0;
    public static final int INTERPRETER_LANGUAGE_CHINESE_MANDARIN  = 1;
    public static final int INTERPRETER_LANGUAGE_CHINESE_TIBETAN   = 2;
    public static final int INTERPRETER_LANGUAGE_CHINESE_CANTONESE = 3;
    public static final int INTERPRETER_LANGUAGE_FIRST = INTERPRETER_LANGUAGE_ENGLISH;
    public static final int INTERPRETER_LANGUAGE_LAST = INTERPRETER_LANGUAGE_CHINESE_CANTONESE;

    public static boolean isValidLanguage(int lang) {
        return lang >= INTERPRETER_LANGUAGE_FIRST && lang <= INTERPRETER_LANGUAGE_LAST;
    }

    public static String getLanguageNameByType(int type, int lang) {
        String ret = null;
        if (lang < INTERPRETER_LANGUAGE_FIRST || lang > INTERPRETER_LANGUAGE_LAST) {
            return ret;
        }
        switch (type) {
            case LANGUAGE_NAME_TYPE_FOR_SPEECH_RECOGNIZER:
                ret = SPEECH_LANG_ARRAY[lang];
                break;
            case LANGUAGE_NAME_TYPE_FOR_ONLINE_TRANSLATOR:
                ret = ONLINE_TRANSLATOR_LANG_ARRAY[lang];
                break;
        }

        return ret;
    }
}
